 //Initialize Select2 Elements
$(".select1").select2();

loadApiGroup();

function commitApi(){
	var vForm = $("#infoDetail");
	validate.init(vForm,mind);
}

function mind(){
	getModal.show({content:'确定提交？',cb_l:cb});
}

function cb(){
	var dataStr = $("#infoDetail").serializeArray();
	var param = {};
    $.each(dataStr,function(i,v){
    	param[v.name] = v.value;
    })  
    console.log(param)
	$.ajax({
		url:'/api/insertApi',
		type:'POST',
		data:param,
	}).done(function(res){
		if(res.success){
			toast.show("新增成功");
		
			returnApi(res.value);
		}else{
			toast.show(res.errorMsg);
		}
	}).fail(function(res){
		toast.show(res.errorMsg);
	})
}



function returnApi(id){
	window.location = "/api/editApi?id="+id;
}